package com.leapp.sk.sever.personal

import android.content.Context
import android.support.v7.app.AppCompatActivity
import com.example.util.ObjectProcessingUtil
import com.leapp.sk.R
import com.leapp.sk.bean.PersonalInfoEntity
import com.leapp.sk.bean.PersonalMineDataEntity
import com.leapp.sk.bean.response.personal.PersonalInfoResponseEntity
import com.leapp.sk.bean.response.personal.PersonalMineResponseEntity
import com.leapp.sk.viewdelegate.MyDelegate
import com.leapp.sk.viewdelegate.personal.PersonalDataDelegate

/**
 * 个人资料逻辑处理
 * @author  chaohaipeng  on 2018/8/21.
 */
class PersonalDataSever {
    private object mHolder {
        val instance = PersonalDataSever()
    }
    companion object {
        fun getInstance(): PersonalDataSever {
            return mHolder.instance
        }
    }

    /**
     * 绑定数据
     */
    fun binderData(context: Context, viewDelegate: PersonalDataDelegate, obj: PersonalInfoResponseEntity?){
        val personalMineDataEntity: PersonalInfoEntity = ObjectProcessingUtil.objMandatoryConversionClass(obj?.data, PersonalInfoEntity::class.java)
        viewDelegate?.setHeadData(personalMineDataEntity.avatar)
        viewDelegate?.setPhone(personalMineDataEntity.phone)
        viewDelegate?.setNick(personalMineDataEntity.nickName)
        viewDelegate?.setIntroduce(personalMineDataEntity.introduction)
        viewDelegate?.setBrith(personalMineDataEntity.birthday)
        viewDelegate?.setName(personalMineDataEntity.name)
        if (personalMineDataEntity.sex==0){
            viewDelegate?.setSexData(context.resources?.getString(R.string.string_personal_dialog_female))
        }else{
            viewDelegate?.setSexData(context.resources?.getString(R.string.string_personal_dialog_male))
        }

    }
}